from datetime import datetime

from exts import db


class Usermodel(db.Model):
    __tablename__ = 'user'
    id = db.Column(db.Integer, primary_key=True,autoincrement=True)
    username = db.Column(db.String(20), nullable=False)
    password = db.Column(db.String(20), nullable=False)
    email = db.Column(db.String(50), nullable=False, unique=True)
    bio = db.Column(db.Text, default="这个人什么都没留下")
    join_time = db.Column(db.DateTime, nullable=False, default=datetime.utcnow) # utcnow表示当前数据的加入时间

class Conversation(db.Model):
    __tablename__ = 'conversations'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    user_input = db.Column(db.Text, nullable=False)
    model_response = db.Column(db.Text)
    create_time = db.Column(db.DateTime, nullable=False,default=datetime.utcnow)# utcnow表示当前数据的加入时间
    # 外键
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)